package com.trkj.utils;

import java.io.IOException;
import java.util.Set;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class PermissionsTag extends SimpleTagSupport{
	private Integer id;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Override
	public void doTag() throws JspException, IOException {
		PageContext pc = (PageContext) this.getJspContext();
		HttpSession session = pc.getSession();
		@SuppressWarnings("unchecked")
		Set<Integer> set = (Set<Integer>) session.getAttribute("perids");
		System.err.println(set.size());
		if(set.contains(id)) {
            this.getJspBody().invoke(null);
		}
	}
}
